import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import { useAuthStore } from '@/stores/auth'
// 引入element plus组件
import * as Icons from '@element-plus/icons-vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

import { Icon } from '@iconify/vue'

const app = createApp(App)
const pinia = createPinia()
import mUI from './components'
import './mock'
// style引入
import './assets/font/iconfont.css'
import './assets/css/main.scss'
import './assets/css/tailwind.css'
// 插件
import './plugins/echarts'
import './plugins'
// 自定义指令
import directives from './directives'

// 注册element-plus 图标全部组件
app.use(directives)
for (const [key, component] of Object.entries(Icons)) {
  app.component(key, component)
}
// 注册 IconifyIcon 图标
app.component('Icon', Icon)
app.use(pinia)
app.use(router)
app.use(mUI)
app.use(ElementPlus)
app.mount('#app')

// 检查用户登录状态
const authStore = useAuthStore()
authStore.checkAuth()
